﻿#ifndef __SS_DISPATCH_H__
#define __SS_DISPATCH_H__
#include "../ssBaseDefine.h"
#include "../container/stdHashmap.h"


namespace StarSeeker
{

#define SS_EVENT_MAP(evnId, func)		m_func_map[evnId] = (fcEventPtr)(&func);

class ssDispatch
{
public:
	ssDispatch()
	{
	}

	virtual ~ssDispatch()
	{
	}

	bool Dispatch(u32 evnId, u32 subId, ulint param1, ulint param2)
	{
		map_it it = m_func_map.find(evnId);
		if (it != m_func_map.end())
		{
			return (this->*(it->second))(subId, param1, param2);
		}
		return 0;
	}

protected:
	typedef bool(ssDispatch::*fcEventPtr)(u32 subId, ulint param1, ulint param2);
	typedef HASH_MAP<u32, fcEventPtr>::iterator map_it;

	HASH_MAP<u32, fcEventPtr>		m_func_map;
};

}
#endif
